/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.agtranscontinental.sisref.model;

import com.agtranscontinental.sisref.dto.DanioDto;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author ericson
 */
@Entity
@Table(name = "danio")
@NamedQueries({
    @NamedQuery(name = "Danio.findAll", query = "SELECT d FROM Danio d"),
    @NamedQuery(name = "Danio.findById", query = "SELECT d FROM Danio d WHERE d.id = :id"),
    @NamedQuery(name = "Danio.findByDccion", query = "SELECT d FROM Danio d WHERE d.dccion = :dccion"),
    @NamedQuery(name = "Danio.findByIsFto", query = "SELECT d FROM Danio d WHERE d.isFto = :isFto"),
    @NamedQuery(name = "Danio.findByIsMdda", query = "SELECT d FROM Danio d WHERE d.isMdda = :isMdda")})
public class Danio implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Size(max = 150)
    @Column(name = "dccion")
    private String dccion;
    @Column(name = "is_fto")
    private Boolean isFto;
    @Column(name = "is_mdda")
    private Boolean isMdda;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "danio")
    private List<Revision> revisionList;

    public Danio() {
    }

    public Danio(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDccion() {
        return dccion;
    }

    public void setDccion(String dccion) {
        this.dccion = dccion;
    }

    public Boolean getIsFto() {
        return isFto;
    }

    public void setIsFto(Boolean isFto) {
        this.isFto = isFto;
    }

    public Boolean getIsMdda() {
        return isMdda;
    }

    public void setIsMdda(Boolean isMdda) {
        this.isMdda = isMdda;
    }

    public List<Revision> getRevisionList() {
        return revisionList;
    }

    public void setRevisionList(List<Revision> revisionList) {
        this.revisionList = revisionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Danio)) {
            return false;
        }
        Danio other = (Danio) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agtranconstinental.sisref.Danio[ id=" + id + " ]";
    }
    
    public DanioDto toDanioDto(){
        DanioDto d = new DanioDto();
        d.setId(getId());
        d.setDccion(getDccion());
        d.setIsFto(getIsFto());
        d.setIsMdda(getIsMdda());
        return d;
    }
}
